<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "https://raw.githubusercontent.com/rbatis/rbatis/master/rbatis-codegen/mybatis-3-mapper.dtd">
<mapper>
    <select id="select_by_condition">
        `select `
        <if test="code_len >= 2">
            `province.area_name province_name, `
            `province.area_code province_code, `
        </if>
        <if test="code_len >= 4">
            `city.area_name city_name,`
            `city.area_code city_code,`
        </if>
        <if test="code_len >= 6">
            `district.area_name district_name,`
            `district.area_code district_code,`
        </if>
        <if test="code_len  >= 9">
            `street.area_name street_name,`
            `street.area_code street_code `
        </if>
        `from db_wms.ts_areas province `
        <if test="code_len  >= 4">
            `inner join db_wms.ts_areas city on city.parent_id = province.area_code `
        </if>
        <if test="code_len  >= 6">
            `inner join db_wms.ts_areas district on district.parent_id = city.area_code `
        </if>
        <if test="code_len  >= 9">
            `inner join db_wms.ts_areas street on street.parent_id = district.area_code `
        </if>
        `where `
<!--        <if test="code_len >= 2 and 1==1">-->
<!--            <if test="4 >code_len">-->
<!--            `province.area_code = #{code}`-->
<!--            </if>-->
<!--        </if>-->
<!--        <if test="code_len >= 4 ">-->
<!--            <if test="6>code_len">-->
<!--            city.area_code = #{code}-->
<!--            </if>-->
<!--        </if>-->
<!--        <if test="code_len >= 6 ">-->
<!--            <if test="9>code_len">-->
<!--            district.area_code = #{code}-->
<!--            </if>-->
<!--        </if>-->
        <if test="code_len >= 9">
            `street.area_code = #{code} `
        </if>

    </select>
</mapper>